//
//  CTMediator+LoginCompoentActions.m
//  VPLoginComponentForPod
//
//  Created by verne on 2016/12/29.
//  Copyright © 2016年 vernepung. All rights reserved.
//
#import "CTMediator+LoginCompoentActions.h"
NSString *const kCTMediatorLoginAction = @"VPLogin";

NSString *const kCTMediatorLoginActionNativeFetchLoginViewController = @"fetchLoginViewController";

@implementation CTMediator (LoginCompoentActions)
- (BaseViewController *)CTMediator_viewControllerForLoginWithAppLogo:(NSString *)logo
                                                         oldUserName:(NSString *)userName
                                                    userNameLeftIcon:(NSString *)uLeftIcon
                                                         oldPassword:(NSString *)password
                                                    passwordLeftIcon:(NSString *)pLeftIcon
                                                   showPasswordImage:(NSString *)showImage
                                                   hidePasswordImage:(NSString *)hideImage
                                          loginButtonBackgroundColor:(UIColor *)bgColor
                                                  loginButtonClicked:(NSString * (^)(NSDictionary * info))clickedBlock
                                                   commandTitleArray:(NSArray<NSString *> *)titles
                                                  commandImagesArray:(NSArray<NSString *> *)images
                                                           copyright:(NSString *)copyright
                                                  copyrightTextColor:(UIColor *)copyrightColor
                                                   copyrightTextFont:(UIFont *)copyrightFont
                                                executedCommandBlock:(void (^)(NSInteger index))executedCommandBlock{
    if (titles.count != images.count) return nil;
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setObject:logo ?: @"" forKey:@"logo"];
    [params setObject:userName ?: @"" forKey:@"username"];
    [params setObject:uLeftIcon ?: @"" forKey:@"uLeftIcon"];
    [params setObject:password ?: @"" forKey:@"password"];
    [params setObject:pLeftIcon ?: @"" forKey:@"pLeftIcon"];
    [params setObject:showImage ?: @"" forKey:@"showPasswordImageName"];
    [params setObject:hideImage ?: @"" forKey:@"hidePasswordImageName"];
    if (bgColor){
        [params setObject:bgColor forKey:@"bgColor"];
    }
    if (clickedBlock){
        [params setObject:clickedBlock forKey:@"btnloginClicked"];
    }
    if (executedCommandBlock){
        [params setObject:executedCommandBlock forKey:@"executedCommandBlock"];
    }
    if (titles && titles.count > 0){
        [params setObject:titles forKey:@"titles"];
    }
    
    if (images && images.count > 0){
        [params setObject:images forKey:@"images"];
    }
    
    [params setObject:copyright ?: @"" forKey:@"copyright"];
    if (copyrightFont){
        [params setObject:copyrightFont forKey:@"copyrightFont"];
    }
    if (copyrightColor){
        [params setObject:copyrightColor forKey:@"copyrightColor"];
    }
    //    @"copyright":copyright
    //    @"copyrightFont":copyrightFont
    //    @"copyrightColor":copyrightColor
    
    return [self performTarget:kCTMediatorLoginAction action:kCTMediatorLoginActionNativeFetchLoginViewController
                        params:params
             shouldCacheTarget:NO];
    return nil;
}



@end
